<?php

class SendMsg
{

    static $arr = array();
    // 消息内容存储

    // 组装数据
    public static function send($data)
    {

        $msg = json_encode($data);
        
        return self::doSend($msg);
    }
    // 执行发送
    public static function doSend($data)
    {

        $to = "127.0.0.1:2347";

        $handle = stream_socket_client("udp://{$to}", $errno, $errstr, 1);
        
        if (! $handle) {
            
            return false;
        }
        return stream_socket_sendto($handle, $data) == strlen($data);
    }


}

$send=new SendMsg();

$pram=array();
$pram['xm']='ceshi';
$pram['fun']='login';
$pram['userid']=123;
$pram['brandsid']='sky';
$pram['channelid']='guanwang';
$pram['login_time']=time();
$pram['login_ip']="45.78.78.49";
$pram['device_type']=1;
$pram['app_version']='1.0.1';


$send::send($pram);



